<?php

require_once("HtmlPrinter.php");
require_once("Transaction.php");

class TransactionPrinter extends HtmlPrinter
{
	public function print_transactions($transactions)
	{
		$this->pOpen("<table>");
		foreach ($transactions as $transaction)
		{
			$this->print_transaction($transaction);
		}
		$this->pClose("</table>");
	}

	public function print_transaction($transaction)
	{
		$this->pOpen("<tr>");
			$this->p("<td>".$transaction->date."</td>");
			$this->p("<td>$".$transaction->amount."</td>");
		$this->pClose("</tr>");
	}
}

$boa = new BankAccount(1, "Bank of America", 200, "06/22/2011");
$chase = new BankAccount(2, "Chase", 1800, "06/22/2011");

$transactions[] = new Transaction(1, "01/05/2011", 100, $chase);
$transactions[] = new Transaction(2, "04/06/2011", 15, $chase);
$transactions[] = new Transaction(3, "12/23/2011", 27.95, $boa);

$printer = new TransactionPrinter();
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Transactions</title>
	</head>
	<body>
<?php
		$printer->tabs = "\t\t";
		$printer->print_transactions($transactions);
?>
	</body>
</html>